<?php

class Modelos extends Model {

	
	var $modelos = array();

 
    function Modelos()
    {
        // Call the Model constructor
        parent::Model();
    }
	

	function guardarArray(){
		
		$this->cargarModelosAdmin();
		//$this->cargarModelosDocente();
		
		//$this->modelos = $this->getPermisosVisitante();
		
		
		$info = array();
		$info['tipo'] = 'Administrador';
		//$info['descripcion'] = 'Visitante';
		$info['privilegios'] = serialize($this->modelos);
		
		// Diego usa:1
		// Javi usa: 55
		// Seba usa: 55
		
		//$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '1') );
	
	}
	
	function actulaizarPerfiles(){
		
		// Perfil Administrador
		$this->cargarModelosAdmin();
		
		$permisos = $this->modelos;
//echo '<pre>';print_r($permisos); exit;
		$info = array();
		$info['tipo'] = 'Administrador';
		$info['privilegios'] = serialize($permisos);
				
		$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '1') );


	
		// Perfil Visitante
		// Perfil Alumno
		$permisos = $this->getPermisosVisitante();
		
		$info = array();
		$info['tipo'] = 'Alumno';
		//$info['tipo'] = 'Visitante';
		$info['privilegios'] = serialize($permisos);
				
		$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '3') );
		
		$info['tipo'] = 'Visitante';
		$this->db->update('tipodeusuario', $info, array('idtipodeusuario' => '4') );
		
		
		
		
	}
	
	
	function obtenerArray($idTipoUsuario){
		
		// no comenten nada, solo agreguen el idtipodeusuario que quieren actualizar. ( notar que ahora se usa update )
		// cierren y abran sesion y listo. ( ademas de agregar el modelo que querian agregar, obvio )
		//$this->guardarArray();
		$this->actulaizarPerfiles();
		
		
		$this->db->from('tipodeusuario');
		$this->db->where('idtipodeusuario',$idTipoUsuario);
		$query = $this->db->get();
		
		foreach ($query->result() as $fila)
		{
			//echo $fila->idtipodeusuario;
			//echo $fila->tipo;
			$arraydatos['privilegios'] = unserialize($fila->privilegios);
			$arraydatos['tipodeusuario'] = $fila->tipo;
			/*echo '<PRE>';
			print_r($arraydatos);
			echo '</PRE>';
			exit(0);*/
		}
		return $arraydatos;
	}
	
	
	
	function cargarModelosAdmin(){
	
		$this->modelos = array();
	
		$this->modelos["conquer"] = array("realname" => "conquer",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["carta"] = array("realname" => "carta",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["ciudad"] = array("realname" => "ciudad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["clientes"] = array("realname" => "clientes",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["dueno"] = array("realname" => "dueno",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["duenoxpublicidad"] = array("realname" => "duenoxpublicidad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["duenoxresto"] = array("realname" => "duenoxresto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["foto"] = array("realname" => "foto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["horario"] = array("realname" => "horario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["mesa"] = array("realname" => "mesa",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["plato"] = array("realname" => "plato",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["publicidad"] = array("realname" => "publicidad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["puntos"] = array("realname" => "puntos",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["reserva"] = array("realname" => "reserva",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		
		$this->modelos["restaurant"] = array("realname" => "restaurant",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["salon"] = array("realname" => "salon",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["tipocarta"] = array("realname" => "tipocarta",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["tipousuario"] = array("realname" => "tipousuario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["usuario"] = array("realname" => "usuario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["zona"] = array("realname" => "zona",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
	
		
		$this->modelos["platoxfoto"] = array("realname" => "platoxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["restaurantxfoto"] = array("realname" => "restaurantxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$this->modelos["salonxfoto"] = array("realname" => "salonxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$this->modelos["salonfecha"] = array("realname" => "salonfecha",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
	}
	
	
	
	
	function getPermisosVisitante(){
	
		$permisos = array();
	
		$permisos["conquer"] = array("realname" => "conquer",
			"ver" => "0","agregar" => "0","modificar" => "0","eliminar" => "0" 
		);

		$permisos["conquer"] = array("realname" => "conquer",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$permisos["carta"] = array("realname" => "carta",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$permisos["ciudad"] = array("realname" => "ciudad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$permisos["clientes"] = array("realname" => "clientes",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["dueno"] = array("realname" => "dueno",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["duenoxpublicidad"] = array("realname" => "duenoxpublicidad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["duenoxresto"] = array("realname" => "duenoxresto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["foto"] = array("realname" => "foto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["horario"] = array("realname" => "horario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["mesa"] = array("realname" => "mesa",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["plato"] = array("realname" => "plato",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["publicidad"] = array("realname" => "publicidad",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["puntos"] = array("realname" => "puntos",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["reserva"] = array("realname" => "reserva",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		
		$permisos["restaurant"] = array("realname" => "restaurant",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["salon"] = array("realname" => "salon",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["tipocarta"] = array("realname" => "tipocarta",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["tipousuario"] = array("realname" => "tipousuario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["usuario"] = array("realname" => "usuario",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["zona"] = array("realname" => "zona",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
	
		
		$permisos["platoxfoto"] = array("realname" => "platoxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["restaurantxfoto"] = array("realname" => "restaurantxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		
		$permisos["salonxfoto"] = array("realname" => "salonxfoto",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);

		$permisos["salonfecha"] = array("realname" => "salonfecha",
			"ver" => "1",
			"agregar" => "1",
			"modificar" => "1",
			"eliminar" => "1"
		);
		return $permisos;
		
	}
	
	
}

?>
